package von.seiji.cn.test;

import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import org.junit.Test;
import org.springframework.web.multipart.MultipartFile;
import von.seiji.cn.*;

import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;

/**
 * @Author: Amasawa Seiji
 * @Since: 2021/1/9 5:44
 * @Description: 暂无描述
 */
public class T2 {

    public Collection<?> convert(String json) {

        return JSON.parseObject(json, new TypeReference<Collection<?>>() {
        }.getType());
    }

    public Collection convert1(String json, Class<? extends Collection> clazz) {

        return Collection.class.cast(JSON.parseObject(json, clazz));


    }

    @Test
    public void test1() {
        String str = "[{\"top\":0,\"left\":0,\"bottom\":375,\"right\":500}]";
        List<HashMap<String, Object>> list = (List<HashMap<String, Object>>) convert1(str, List.class);
        System.out.println("objects.size() = " + list.size());
        System.out.println(list);
        System.out.println("list.get(0).get(\"bottom\") = " + list.get(0).get("bottom"));

    }

    @Test
    public void test() {
       /* String reverse = StrUtil.reverse("1234567890");
        System.out.println("reverse = " + reverse);*/

    }

    @Test
    public void test15() {
      /*  System.out.println("1111" + (IoUtil.LINE_SEPARATOR == "\r\n") + "2222");
        System.out.println(Arrays.toString(IOUtil.LINE_SEPARATOR.getBytes()));
        System.out.println(ArrayUtil.toString(IOUtil.LINE_SEPARATOR.toCharArray()));*/
    }

    @Test
    public void test57() throws IOException {
        ImageInputStream stream = ImageIO.createImageInputStream(new File(""));


    }

    @Test
    public void test58() {
        System.out.println(IdUtil.getSnowflake(0L, 0L));

        String[] strings = new String[]{"32324", "343"};
        String[] clone = strings.clone();
        strings[0] = "1111111";
        System.out.println(Arrays.toString(clone));
      /*  Map map = ArrayUtil.to(new String[]{"32324", "343"});
        System.out.println(map);
        Set set = map.keySet();
        System.out.println(set);*/
    }

    @Test
    public void test63() {
        String[] strings = new String[]{"323443434324", "343"};
        System.out.println(ArrayUtil.toString(strings));
//        System.out.println(ArrayUtil.toString(ArrayUtil.add(strings, "777777777")));
        System.out.println((char) 0);
        System.out.println((String) null);
        MultipartFile multipartFile = new MultipartFile() {
            @Override
            public String getName() {
                return null;
            }

            @Override
            public String getOriginalFilename() {
                return null;
            }

            @Override
            public String getContentType() {
                return null;
            }

            @Override
            public boolean isEmpty() {
                return false;
            }

            @Override
            public long getSize() {
                return 0;
            }

            @Override
            public byte[] getBytes() throws IOException {
                return new byte[0];
            }

            @Override
            public InputStream getInputStream() throws IOException {
                return null;
            }

            @Override
            public void transferTo(File dest) throws IOException, IllegalStateException {

            }
        };
    }

    @Test
    public void test129() {
        Integer a = 3;//11
        int i1 = Integer.lowestOneBit(9);
        int i = Integer.highestOneBit(3);//11
        System.out.println(i1);
        System.out.println(i);
        int a1 = 0b010010011;
    }

    @Test
    public void test141() {
        System.out.println(0xffffffff);
        int a = 0b11111111_11111111_11111111_11111111;
        System.out.println(a);

        System.out.println(0b111);
        System.out.println(Integer.toBinaryString(-1));
        System.out.println(0x80000003);
        int a2 = 0b10000000_00000000_00000000_00000000;
        System.out.println(a2);
        System.out.println(Integer.toBinaryString(-2147483648));
    }

    @Test
    public void test156() {
        double[][] doubles = new double[4][4];
        doubles[0] = new double[]{1, 4, 6, 9};
        doubles[1] = new double[]{14, 42, 63, 94};
        doubles[2] = new double[]{4, 7, 5, 92};
        doubles[3] = new double[]{13, 74, 86, 94};
        double v = SelfUtil.scoreDeterminants(doubles);
        System.out.println(v);

    }

/*    @Test
    public void test167() {

        double[][] doubles = new double[4][4];
        doubles[0] = new double[]{1,4,6,9};
        doubles[1] = new double[]{14,42,63,94};
        doubles[2] = new double[]{4,7,5,92};
        doubles[3] = new double[]{13,74,86,94};
        double v = SelfUtil.scoreDeterminants1(doubles);
        System.out.println(v);
    }*/

    @Test
    public void test189() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("------------------------------->");
                for (int i = 0; i < 10; i++) {
                    double[][] doubles = new double[4][4];
                    doubles[0] = new double[]{1, 4, 6, 9};
                    doubles[1] = new double[]{14, 42, 63, 94};
                    doubles[2] = new double[]{4, 7, 5, 92};
                    doubles[3] = new double[]{13, 74, 86, 94};
                    double v = SelfUtil.scoreDeterminants(doubles);
                    System.out.println(v);
                }
            }
        }).start();

    }


}
